VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "TestEquality"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
Option Explicit

Private mEquals As VBUnit2.Equality
Private mResult As Boolean


Public Sub testIntegersEqual()
whenComparing 1, 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testIntegersNotEqual()
whenComparing 1, 2
thenResultIs False
thenMessageIs "1 is not the same as 2"
End Sub
Public Sub testIntegersDontMatchStrings()
whenComparing 1, "1"
thenResultIs False
thenMessageIs "Expected Numbers"
End Sub
Public Sub testLongs()
whenComparing CLng(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testSingles()
whenComparing CSng(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testDoubles()
whenComparing CDbl(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testCurrency()
whenComparing CCur(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testDecimals()
whenComparing CDec(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testBytes()
whenComparing CByte(1), 1
thenResultIs True
thenMessageIs "1 is the same as 1"
End Sub
Public Sub testBooleans()
whenComparing True, True
thenResultIs True
thenMessageIs "True is the same as True"
End Sub
Public Sub testBooleansNotEqual()
whenComparing True, False
thenResultIs False
thenMessageIs "True is not the same as False"
End Sub
Public Sub testBooleansDontMatchStrings()
whenComparing True, "True"
thenResultIs False
thenMessageIs "Expected Booleans"
End Sub
Public Sub testDates()
whenComparing CDate(1), CDate(1)
thenResultIs True
thenMessageIs "31/12/1899 is the same as 31/12/1899"
End Sub
Public Sub testNothings()
whenComparing Nothing, Nothing
thenResultIs True
thenMessageIs "Nothing is the same as Nothing"
End Sub
Public Sub testMe()
whenComparing Me, Me
thenResultIs True
thenMessageIs "TestEquality is the same as TestEquality"
End Sub
Public Sub testMeIsNotNothing()
whenComparing Me, Nothing
thenResultIs False
thenMessageIs "TestEquality is not the same as Nothing"
End Sub
Public Sub testEmptyValues()
whenComparing Empty, Empty
thenResultIs True
thenMessageIs "Empty is the same as Empty"
End Sub
Public Sub testNullValues()
whenComparing Null, Null
thenResultIs True
thenMessageIs "Null is the same as Null"
End Sub
Public Sub testEmptyVsNull()
whenComparing Empty, Null
thenResultIs False
thenMessageIs "Expected Empty"
End Sub
Public Sub testNullVsEmpty()
whenComparing Null, Empty
thenResultIs False
thenMessageIs "Expected Null"
End Sub
Public Sub testSameCollection()
Dim c1 As New Collection
whenComparing c1, c1
thenResultIs True
thenMessageIs "Collection is the same as Collection"
End Sub
Public Sub testDifferentCollections()
Dim c1 As New Collection
Dim c2 As New Collection
whenComparing c1, c2
thenResultIs False
thenMessageIs "Collection is not the same as Collection"
End Sub

Public Sub testErrorType()
Dim E As Variant
E = CVErr(1)
assert.equals VarType(E), vbError, "Integer value is error type"
End Sub
Public Sub testErrorValues()
whenComparing CVErr(1), CVErr(2)
thenResultIs False
thenMessageIs "Error 1 is not the same as Error 2"
End Sub
Public Sub testShortStrings()
whenComparing "a", "a"
thenResultIs True
thenMessageIs "<a> is the same as <a>"
End Sub


''
Private Sub whenComparing(actual As Variant, expected As Variant)
mResult = mEquals.equals(actual, expected)
End Sub

Private Sub thenResultIs(result As Boolean)
assert.equals mResult, result, "returned value is " + CStr(result)
assert.equals mEquals.result, result, "result property is " + CStr(result)
End Sub

Private Sub thenMessageIs(message As String)
assert.equals mEquals.message, message, "message is: '" + message + "'"
End Sub

'OPTIONAL METHODS
Public Sub setup()
Set mEquals = New VBUnit2.Equality
End Sub

Public Function NumOfAsserts() As Long
NumOfAsserts = 73
End Function
